<?php


namespace app\index\model;

use think\Model;
use app\index\inter\DbInter;

class Base extends Model implements DbInter
{
    protected $insert =[
        'cTime'
    ];
    public function selectModel($data=[]){
        return $this->where($data['field'],$data['op'],$data['value'])
            ->order('cTime desc')
            ->select();
    }
    public function updateModel($data=[])
    {
        $this->save($data,[$data['field']=>$data['value']]);
    }
    public function deleteModel($data=[])
    {
        $this->where($data['field'],$data['op'],$data['value'])
            ->delete();
    }
    public function saveModel($data=[]){
        $this->data($data);
        $this->save();
        return $this;
    }
    public function setcTimeAttr()
    {
        return time();
    }
    public function getcTimeAttr($t)
    {
        return Date('Y-m-d H:i:s',$t);
    }
    public function getimgAttr($img)
    {
        $host_public=config('host_public');
        return $host_public.$img;
    }
}